<template>
	<view class="select-doctor-wrapper">
		<view class="doctor-item" v-for="(doctor, index) in doctorList" :key="index"
			@click="api_user_addcforder(doctor)">
			<view class="left-icon">
				<image :src="doctor.advertisement"></image>
			</view>
			<view class="center-wrapper">
				<p>{{doctor.z_name}}</p>
				<p class="sub-p">{{doctor.keshi}} - {{doctor.hospital}}</p>
				<p class="desc-p">{{doctor.authority}}</p>
				<p></p>
				<view class="toolbar">

				</view>
			</view>
			<view class="right-label" @click="api_user_addcforder(doctor)">
				<span>开方</span>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				formData: {},
				j_id: '',
				deptid: '',
				doctorList: []
			}
		},
		onLoad(option) {
			this.formData = option.formData
			this.j_id = option.j_id
			this.deptid = option.deptid
			this.api_getlistall(this.deptid)
		},
		methods: {
			api_user_addcforder(doctor) {
				uni.showModal({
					title: '提示',
					content: '确定开方吗？',
					success: (res) => {
						if (res.confirm) {
							let openid = uni.getStorageSync('openid')
							let currentUserCard = uni.getStorageSync('current_user_card')
							let data = {
								// openid: 'oDk0K4wD10i-QyvEJlO2aFMcSYH0',
								openid: openid,
								zid: doctor.zid,
								key_words: 'yuanchengkaifang',
								conets: this.formData,
								money: 0,
								j_id: this.j_id,
								ifgk: 0,
								addnum: 0,
								coupon_dk: 0,
								old_money: 0,
								coupon_id: '',
								yid: '',
								year_dk: 0
							}
							console.log(data)
							this.$app._get('entry/wxapp/user.addcforder', data, (result) => {
								console.log(result)
								uni.redirectTo({
									url: '/pages/global/successMessage?msg=' + '开方成功'
								})
							})
						} else if (res.cancel) {

						}
					}
				});
			},
			api_getlistall(deptid) {
				this.$app._get('entry/wxapp/zhuanjia.getlistall', {
					id: deptid,
					biaoqian: '',
					page: 0,
					pagback: 100,
					server_key: 'yuanchengkaifang'
				}, (result) => {
					console.log(result)
					this.doctorList = result
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.select-doctor-wrapper {
		padding: 15px;

		.doctor-item {
			position: relative;
			display: flex;
			flex-direction: row;
			border-bottom: 1px solid #EEEEEE;
			background-color: #fff;
			padding: 12px 15px;

			.left-icon {
				width: 50px;
				height: 50px;
				border-radius: 50px;
				background-color: #2096F3;
				display: flex;
				flex-direction: row;
				align-items: center;
				text-align: center;
				justify-content: center;

				image {
					width: 30px;
					height: 30px;
				}
			}

			.center-wrapper {
				display: flex;
				flex: 1;
				flex-direction: column;
				padding-left: 10px;
				font-size: 1rem;

				.sub-p {
					font-size: 0.8rem;
					color: #757575;
				}

				.desc-p {
					font-size: 0.7rem;
					color: #757575;
				}
			}

			.right-label {
				display: flex;
				flex-direction: row;
				justify-content: flex-end;
				align-items: center;

				span {
					font-size: 0.6rem;
					background-color: #2196f3;
					color: #fff;
					padding: 5px 7px 5px 7px;
					border-radius: 10px;
				}
			}
		}
	}
</style>